package com.bifrost.entity;

import lombok.EqualsAndHashCode;

import java.io.Serializable;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the MERCHANT_STORE database table.
 */
@Entity
@Table(name = "MERCHANT_STORE")
@NamedQuery(name = "MerchantStore.findAll", query = "SELECT m FROM MerchantStore m WHERE m.isDefault is empty  or m.isDefault = false order by merchantId desc")
@EqualsAndHashCode
public class MerchantStore implements Serializable {

    private static final long serialVersionUID = -3071547380538426552L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "MERCHANT_ID", unique = true, nullable = false)
    private Long merchantId;
    @Column(name = "IS_AVAILABLE")
    private Boolean available = Boolean.TRUE;

    @Column(name = "CONTINUE_SHOPPING_URL", length = 255)
    private String continueShoppingUrl;

    @Column(name = "DOMAIN_NAME", length = 80)
    private String domainName;

    @Column(name = "INVOICE_TEMPLATE", length = 25)
    private String invoiceTemplate;

    @Column(name = "STORE_ADDRESS", length = 255)
    private String storeAddress;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STORE_CITY", nullable = false ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private CountryArea storeCity =new CountryArea(60L);

    @Column(name = "STORE_CODE", nullable = false, length = 100)
    private String storeCode;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STORE_COUNTRY", nullable = false ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Country storeCountry  =new Country(1L);

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STORE_DISTRICT", nullable = false ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private CountryArea storeDistrict =new CountryArea(61L);


    @Column(name = "STORE_NAME", nullable = false, length = 100)
    private String storeName;

    @Column(name = "STORE_PHONE", length = 50)
    private String storePhone;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STORE_STATE", nullable = false ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private CountryArea storeState  =new CountryArea(59L);

    @Column(name = "STORE_STREET", length = 255)
    private String storeStreet;

    @Column(name = "STORE_TEMPLATE", length = 25)
    private String storeTemplate;

    @Column(name = "UPDATED_BY", length = 64)
    private String updatedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATED_TIMESTAMP")
    private Date updatedTimestamp;

    @Column(name = "RATES_COUNT")
    private Integer ratesCount;

    @Column(name = "ORDER_COUNT")
    private Integer orderCount;

    @Column(name = "IS_DEFAULT")
    private Boolean isDefault;

    @Column(name = "SHIPMENT_MODE", length = 100)
    private String shipmentMode;

    @Column(name = "PRICE_ADJUSTMENT_MODE", length = 64)
    private String priceAdjustmentMode;

    //bi-directional many-to-one association to Category
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Category> categories;

    //bi-directional many-to-one association to Media
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Media> medias;

    //bi-directional many-to-one association to MerchantAttribute
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<MerchantAttribute> merchantAttributes;

    //bi-directional many-to-one association to Media
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "STORE_LOGO" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Media media;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<MerchantConfiguration> merchantConfigurations;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<IndexSettingRegion> indexSettingRegions;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<MerchantConfiguration> customers;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<User> users;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Promotion> promotions;

    @Column(name = "IMG_ALT_1")
    private Long alt1;

    @Column(name = "IMG_ALT_2")
    private Long alt2;

    @Column(name = "IMG_ALT_3")
    private Long alt3;

    @Column(name = "IMG_ALT_4")
    private Long alt4;
    @Column(name = "SORT_ORDER", precision = 11)
    private Integer sortOrder = 1;

    @Lob
    @Column(name = "DESCRIPTION")
    private String description;

    @Column(name = "LONGITUDE", precision = 19, scale = 7)
    private BigDecimal longitude;

    @Column(name = "LATITUDE", precision = 19, scale = 7)
    private BigDecimal latitude;

    //bi-directional many-to-one association to Order
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Order> orders;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderReturn> orderReturns;

    //bi-directional many-to-one association to ProductBrand
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductBrand> productBrands;

    //bi-directional many-to-one association to ProductOption
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductOption> productOptions;

    //bi-directional many-to-one association to ProductService
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ProductService> productServices;

    //bi-directional many-to-one association to ServiceShop
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ServicePrice> servicePrices;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<OrderItemService> orderItemServices;
    //bi-directional many-to-one association to ShoppingCart
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ShoppingCart> shoppingCarts;

    //bi-directional many-to-one association to Warehouse
    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Warehouse> warehouses;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<StoreMediaMap> storeMediaMaps;

    @Column(name = "EXTERNAL_ID", length = 32,nullable = false)
    private String externalId;

    @OneToMany(mappedBy = "merchantStore")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<ShoppingCartItem> shoppingCartItems;

    @OneToMany(mappedBy = "releaseBy", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Coupon> coupons;

    @OneToMany(mappedBy = "merchantStore", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<CouponMerchant> couponMerchants;

    @OneToMany(mappedBy = "merchantStore", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<BonusPointsStore> bonusPointsStores;

    public MerchantStore() {
    }

    public Long getMerchantId() {
        return this.merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Boolean getAvailable() {
        return available;
    }

    public void setAvailable(Boolean available) {
        this.available = available;
    }

    public String getContinueShoppingUrl() {
        return this.continueShoppingUrl;
    }

    public void setContinueShoppingUrl(String continueShoppingUrl) {
        this.continueShoppingUrl = continueShoppingUrl;
    }


    public String getDomainName() {
        return this.domainName;
    }

    public void setDomainName(String domainName) {
        this.domainName = domainName;
    }

    public String getInvoiceTemplate() {
        return this.invoiceTemplate;
    }

    public void setInvoiceTemplate(String invoiceTemplate) {
        this.invoiceTemplate = invoiceTemplate;
    }

    public String getStoreAddress() {
        return this.storeAddress;
    }

    public void setStoreAddress(String storeAddress) {
        this.storeAddress = storeAddress;
    }

    public CountryArea getStoreCity() {
        return this.storeCity;
    }

    public void setStoreCity(CountryArea storeCity) {
        this.storeCity = storeCity;
    }

    public String getStoreCode() {
        return this.storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public Country getStoreCountry() {
        return this.storeCountry;
    }

    public void setStoreCountry(Country storeCountry) {
        this.storeCountry = storeCountry;
    }

    public CountryArea getStoreDistrict() {
        return this.storeDistrict;
    }

    public void setStoreDistrict(CountryArea storeDistrict) {
        this.storeDistrict = storeDistrict;
    }


    public String getStoreName() {
        return this.storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getStorePhone() {
        return this.storePhone;
    }

    public void setStorePhone(String storePhone) {
        this.storePhone = storePhone;
    }

    public CountryArea getStoreState() {
        return this.storeState;
    }

    public void setStoreState(CountryArea storeState) {
        this.storeState = storeState;
    }

    public String getStoreStreet() {
        return this.storeStreet;
    }

    public void setStoreStreet(String storeStreet) {
        this.storeStreet = storeStreet;
    }

    public String getStoreTemplate() {
        return this.storeTemplate;
    }

    public void setStoreTemplate(String storeTemplate) {
        this.storeTemplate = storeTemplate;
    }

    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Date getUpdatedTimestamp() {
        return this.updatedTimestamp;
    }

    public void setUpdatedTimestamp(Date updatedTimestamp) {
        this.updatedTimestamp = updatedTimestamp;
    }

    public String getExternalId() {
        return externalId;
    }

    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }

    public String getShipmentMode() {
        return shipmentMode;
    }

    public void setShipmentMode(String shipmentMode) {
        this.shipmentMode = shipmentMode;
    }

    public Integer getRatesCount() {
        return ratesCount;
    }

    public void setRatesCount(Integer ratesCount) {
        this.ratesCount = ratesCount;
    }

    public Integer getOrderCount() {
        return orderCount;
    }

    public void setOrderCount(Integer orderCount) {
        this.orderCount = orderCount;
    }

    public Boolean getDefault() {
        return isDefault;
    }

    public void setDefault(Boolean aDefault) {
        isDefault = aDefault;
    }

    public List<Category> getCategories() {
        return this.categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    public Category addCategory(Category category) {
        getCategories().add(category);
        category.setMerchantStore(this);

        return category;
    }

    public Category removeCategory(Category category) {
        getCategories().remove(category);
        category.setMerchantStore(null);

        return category;
    }

    public List<Media> getMedias() {
        return this.medias;
    }

    public void setMedias(List<Media> medias) {
        this.medias = medias;
    }

    public Media addMedia(Media media) {
        getMedias().add(media);
        media.setMerchantStore(this);

        return media;
    }

    public Media removeMedia(Media media) {
        getMedias().remove(media);
        media.setMerchantStore(null);

        return media;
    }

    public Long getAlt1() {
        return alt1;
    }

    public void setAlt1(Long alt1) {
        this.alt1 = alt1;
    }

    public Long getAlt2() {
        return alt2;
    }

    public void setAlt2(Long alt2) {
        this.alt2 = alt2;
    }

    public Long getAlt3() {
        return alt3;
    }

    public void setAlt3(Long alt3) {
        this.alt3 = alt3;
    }

    public Long getAlt4() {
        return alt4;
    }

    public void setAlt4(Long alt4) {
        this.alt4 = alt4;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<MerchantAttribute> getMerchantAttributes() {
        return this.merchantAttributes;
    }

    public void setMerchantAttributes(List<MerchantAttribute> merchantAttributes) {
        this.merchantAttributes = merchantAttributes;
    }

    public MerchantAttribute addMerchantAttribute(MerchantAttribute merchantAttribute) {
        getMerchantAttributes().add(merchantAttribute);
        merchantAttribute.setMerchantStore(this);

        return merchantAttribute;
    }

    public MerchantAttribute removeMerchantAttribute(MerchantAttribute merchantAttribute) {
        getMerchantAttributes().remove(merchantAttribute);
        merchantAttribute.setMerchantStore(null);

        return merchantAttribute;
    }


    public Media getMedia() {
        return this.media;
    }

    public void setMedia(Media media) {
        this.media = media;
    }

    public List<Order> getOrders() {
        return this.orders;
    }

    public void setOrders(List<Order> orders) {
        this.orders = orders;
    }

    public Order addOrder(Order order) {
        getOrders().add(order);
        order.setMerchantStore(this);

        return order;
    }

    public Order removeOrder(Order order) {
        getOrders().remove(order);
        order.setMerchantStore(null);

        return order;
    }

    public List<ProductBrand> getProductBrands() {
        return this.productBrands;
    }

    public void setProductBrands(List<ProductBrand> productBrands) {
        this.productBrands = productBrands;
    }

    public ProductBrand addProductBrand(ProductBrand productBrand) {
        getProductBrands().add(productBrand);
        productBrand.setMerchantStore(this);

        return productBrand;
    }

    public ProductBrand removeProductBrand(ProductBrand productBrand) {
        getProductBrands().remove(productBrand);
        productBrand.setMerchantStore(null);

        return productBrand;
    }

    public List<ProductOption> getProductOptions() {
        return this.productOptions;
    }

    public void setProductOptions(List<ProductOption> productOptions) {
        this.productOptions = productOptions;
    }

    public ProductOption addProductOption(ProductOption productOption) {
        getProductOptions().add(productOption);
        productOption.setMerchantStore(this);

        return productOption;
    }

    public ProductOption removeProductOption(ProductOption productOption) {
        getProductOptions().remove(productOption);
        productOption.setMerchantStore(null);

        return productOption;
    }

    public List<ProductService> getProductServices() {
        return this.productServices;
    }

    public void setProductServices(List<ProductService> productServices) {
        this.productServices = productServices;
    }

    public ProductService addProductService(ProductService productService) {
        getProductServices().add(productService);
        productService.setMerchantStore(this);

        return productService;
    }

    public ProductService removeProductService(ProductService productService) {
        getProductServices().remove(productService);
        productService.setMerchantStore(null);

        return productService;
    }

    public List<ServicePrice> getServicePrices() {
        return this.servicePrices;
    }

    public void setServicePrices(List<ServicePrice> servicePrices) {
        this.servicePrices = servicePrices;
    }

    public ServicePrice addServicePrice(ServicePrice servicePrice) {
        getServicePrices().add(servicePrice);
        servicePrice.setMerchantStore(this);

        return servicePrice;
    }

    public ServicePrice removeServiceShop(ServicePrice servicePrice) {
        getServicePrices().remove(servicePrice);
        servicePrice.setMerchantStore(null);

        return servicePrice;
    }

    public List<ShoppingCart> getShoppingCarts() {
        return this.shoppingCarts;
    }

    public void setShoppingCarts(List<ShoppingCart> shoppingCarts) {
        this.shoppingCarts = shoppingCarts;
    }

    public ShoppingCart addShoppingCart(ShoppingCart shoppingCart) {
        getShoppingCarts().add(shoppingCart);
        shoppingCart.setMerchantStore(this);

        return shoppingCart;
    }

    public ShoppingCart removeShoppingCart(ShoppingCart shoppingCart) {
        getShoppingCarts().remove(shoppingCart);
        shoppingCart.setMerchantStore(null);

        return shoppingCart;
    }

    public List<Warehouse> getWarehouses() {
        return this.warehouses;
    }

    public void setWarehouses(List<Warehouse> warehouses) {
        this.warehouses = warehouses;
    }

    public Warehouse addWarehous(Warehouse warehous) {
        getWarehouses().add(warehous);
        warehous.setMerchantStore(this);

        return warehous;
    }

    public Warehouse removeWarehous(Warehouse warehous) {
        getWarehouses().remove(warehous);
        warehous.setMerchantStore(null);

        return warehous;
    }

    public List<OrderItemService> getOrderItemServices() {
        return orderItemServices;
    }

    public void setOrderItemServices(List<OrderItemService> orderItemServices) {
        this.orderItemServices = orderItemServices;
    }

    public String getPriceAdjustmentMode() {
        return priceAdjustmentMode;
    }

    public void setPriceAdjustmentMode(String priceAdjustmentMode) {
        this.priceAdjustmentMode = priceAdjustmentMode;
    }

    public List<StoreMediaMap> getStoreMediaMaps() {
        return storeMediaMaps;
    }

    public void setStoreMediaMaps(List<StoreMediaMap> storeMediaMaps) {
        this.storeMediaMaps = storeMediaMaps;
    }

    public List<ShoppingCartItem> getShoppingCartItems() {
        return shoppingCartItems;
    }

    public void setShoppingCartItems(List<ShoppingCartItem> shoppingCartItems) {
        this.shoppingCartItems = shoppingCartItems;
    }

    public List<Coupon> getCoupons() {
        return coupons;
    }

    public void setCoupons(List<Coupon> coupons) {
        this.coupons = coupons;
    }

    public List<CouponMerchant> getCouponMerchants() {
        return couponMerchants;
    }

    public void setCouponMerchants(List<CouponMerchant> couponMerchants) {
        this.couponMerchants = couponMerchants;
    }


    public BigDecimal getLongitude() {
        return longitude;
    }

    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public List<MerchantConfiguration> getMerchantConfigurations() {
        return merchantConfigurations;
    }

    public void setMerchantConfigurations(List<MerchantConfiguration> merchantConfigurations) {
        this.merchantConfigurations = merchantConfigurations;
    }

    public List<IndexSettingRegion> getIndexSettingRegions() {
        return indexSettingRegions;
    }

    public void setIndexSettingRegions(List<IndexSettingRegion> indexSettingRegions) {
        this.indexSettingRegions = indexSettingRegions;
    }

    public List<MerchantConfiguration> getCustomers() {
        return customers;
    }

    public void setCustomers(List<MerchantConfiguration> customers) {
        this.customers = customers;
    }

    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }

    public List<Promotion> getPromotions() {
        return promotions;
    }

    public void setPromotions(List<Promotion> promotions) {
        this.promotions = promotions;
    }

    public List<OrderReturn> getOrderReturns() {
        return orderReturns;
    }

    public void setOrderReturns(List<OrderReturn> orderReturns) {
        this.orderReturns = orderReturns;
    }
}